package com.w.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Slf4j
public class Interceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        HttpSession session = request.getSession();
        Object ok = session.getAttribute("ok");

//        if (ok != null){
//            //放行
//            return true;
//        }else{
//            //拦截到，跳转到留言界面
//            request.setAttribute("msg","先发个留言呗！");
//            request.getRequestDispatcher("/wall.html").forward(request,response);
//            return false;
//        }
        return true;

    }
}
